package com.demo.mybatis_plus.config;

import com.baomidou.mybatisplus.annotation.DbType;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * MyBatis-Plus的配置类
 */
@Configuration
public class MyBatisPlus {
    /**
     * 拦截器配置
     * @return
     */

    @Bean
    public MybatisPlusInterceptor mybatisPlusInterceptor() {
        // 创建拦截器对象
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        // 创建分页插件
        PaginationInnerInterceptor pagePlugin = new PaginationInnerInterceptor();
        pagePlugin.setDbType(DbType.MYSQL);
        pagePlugin.setOverflow(true);
        // 将分页插件添加到拦截器
        interceptor.addInnerInterceptor(pagePlugin);
        return interceptor;
    }
}
